class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> ret;

        for (int i = 1; i <= numRows; i++)
        {
            vector<int> rowNum;
            for (int j = 0; j < i; j++)
            {
                if (j == 0 || j == i - 1)
                    rowNum.push_back(1);
                else
                {
                    int tmp = ret[i - 2][j] + ret[i - 2][j - 1];
                    rowNum.push_back(tmp);
                }
            }
            ret.push_back(rowNum);
        }

        return ret;
    }
};